import 'package:backend.core/core/domain/entities/api/web/api_web_payment_method_failure.dart';
import 'package:equatable/equatable.dart';

const kApiWebPaymentFailureCardExpiredValue = 'card_expired';
const kApiWebPaymentFailureCardUnavailableValue = 'card_unavailable';

class ApiWebPaymentMethodFailureDto extends Equatable {
  const ApiWebPaymentMethodFailureDto._internal({
    required this.failureString,
  });

  final String failureString;

  @override
  List<Object?> get props {
    return [
      failureString,
    ];
  }

  factory ApiWebPaymentMethodFailureDto.fromEntity(ApiWebPaymentMethodFailure failure) {
    late final String failureString;

    if (failure == ApiWebPaymentMethodFailure.cardExpired) {
      failureString = kApiWebPaymentFailureCardExpiredValue;
    } else if (failure == ApiWebPaymentMethodFailure.cardUnavailable) {
      failureString = kApiWebPaymentFailureCardUnavailableValue;
    }

    return ApiWebPaymentMethodFailureDto._internal(
      failureString: failureString,
    );
  }

  @override
  String toString() {
    return failureString;
  }
}
